<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/reset.css" />
		<link rel="stylesheet" type="text/css" href="css/details.css" />
	</head>
	<body>
		<header></header>
		<section>
			<div class="banxin">
				<div class="shopImg">
					<div class="img">
						
						<div class="swiper-container">
							<!-- 图 。视频 -->
							<div class="swiper-wrapper">
								<div id="tutu">
									<img src="" class="rrr">
									<div class="bigImg" style="display: none;">
										<img class="sku" src="" alt="">
									</div>
								</div>
								<div id="ship" style="display:none">
									<video width="100%" height="349px" controls="controls" autoplay="" src="">
									</video>
								</div>

							</div>
							<!-- 点 -->
							<div class="swiper-pagination">
								<span></span>
								<span id="verdioa"></span>
							</div>
						</div>
					</div>
					<div class="detailsTitle" style="position: relative; height: 470px">
						<div class="detailTop">
							<p class="maidian"
								style="font-family: 'GBK-light'; font-size: 35px; font-weight: 100; text-indent: -20px">
								</p>
							<p class="title1"></p>
						</div>
						<div class="detailBottom" style="position: absolute; left: 0; bottom: 0">
							<div style="width: 50px; border-bottom: 2px solid #999999"></div>
							<div class="title2"></div>
							<p class="size_val" style="float: left">
								<b> </b>
							</p>
							<p class="val" style="float: left; line-height: 37px"></p>
							<ul class="mini_img" style="min-height: 30px; max-height: 120px; overflow-y: auto">
								<li>
									<p></p>
								</li>
							</ul>
							<p class="total" style=" margin-top: 5px; color: red">该商品暂无库存</p>
							<div class="btns">
								<div class="step">
									<i class="reduce">-</i>
									<input class="num" maxlength="2" onkeyup="value=value.replace(/[^\d]/g,'')"
										type="text" value="1" />
									<i class="plus">+</i>
								</div>
								<button class="addCart">加入购物车</button>
								<button class="buy" type="2">立即购买</button>
							</div>
							<div id="fenxiang"> 
							
							</div>
						</div>
					</div>
				 
				</div>
				<h3 style="text-align: left; line-height: 80px; border-bottom: 1px solid #eeeeee">
				     <!-- 商品详情 -->
				   </h3>
				   <div class="detailImg">
				     <img src="" />
				   </div>
			</div>
		</section>
		<footer id="footer"></footer>
	</body>
</html>
<script src="js/jQuery.js" type="text/javascript" charset="utf-8"></script>
<script src="js/cookieTools.js"></script>
<script src="js/details.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">

function GetRequest() {
	   var url = location.search; //获取当前页面url
	   var theRequest = new Object();
	   if (url.indexOf("?") != -1) { 
	      var str = url.substr(1);
	      strs = str.split("&");
	      for(var i = 0; i < strs.length; i ++) { 
	         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
	      }
	   }
	   return theRequest;
	}
	let n=GetRequest();
	let goodid=n['goodsId'];
	$.get("php/getGoodsInfo.php",{
			"goodsId":goodid
		},function(resText,status,xhr){
			resText=JSON.parse(resText);
			$("#tutu img").attr("src",(resText.goodsImg));
			$("#ship video").attr("src",resText.beiyong4);
			$(".detailTop .maidian").html("「 "+resText.goodsName+" 」");
			$(".detailTop .title1").html(resText.goodsDesc);
			$(".detailBottom .title2").html(resText.beiyong1);
			$(".detailBottom .size_val b").html("￥ "+resText.goodsPrice);
			$(".mini_img li p").html(resText.beiyong2);
			$(".detailImg img").attr("src",resText.beiyong3);
			if(resText.goodsCount>0){
				$(".detailBottom .tital").css({
					display:"none"
				})
			}else{
				$(".detailBottom .tital").css({
					display:"block"
				})
			}
			if(resText.beiyong4==""){
				$(" .swiper-pagination #verdioa").css({
					display:"none"
				})
			}
			
			let  imgmask=$("#tutu .rrr").attr("src");
			$(".bigImg img").attr("src",imgmask);
			 Magnifier();
		});
		
		
		$(".addCart").click(function(){
			if(getCookie("vipName")!=""){
			let count=$(".step .num").val();
			let vipName=getCookie("vipName");
			console.log(vipName,goodid,count)
			$.post("php/addShoppingCart.php",{
				"vipName":vipName,
				"goodsId":goodid,
				"goodsCount":count
			}).then(function(resText,status,xhr){
				if(resText==1){
					console.log(111);
					alert("已加入购物车");
				}else{
					console.log(222);
				}
			});
			}else{
				location.href="register.html";				
			}
			
		})
		
		
	
</script>
